#!usr/bin/node

const Koa = require('koa'),
      Router = require('koa-router');

const app = new Koa(),
      router = new Router();

router.get('/api/authors/',async (ctx,next) => {
  console.log('得到漫画书作者列表');
  ctx.body = 'get authors list ok';
});

router.get('/api/authors/:authorName',async (ctx,next) => {
  console.log('按作者名称查询');
  ctx.body = 'get authors by name ok';
});

router.post('/api/authors/',async (ctx,next) => {
  console.log('添加新的漫画书作者信息');
  ctx.body = 'insert ok';
});

router.put('/api/authors/:id',async (ctx,next) => {
  console.log('修改某ID的漫画书作者信息');
  ctx.body = 'update ok';
});

router.delete('/api/authors/:id',async (ctx,next) => {
  console.log('删除某id的漫画书作者信息');
  ctx.body = 'delete ok';
});

app.use(router.routes());

app.listen(8080);
